
#[inline(always)]
pub fn encode_u8(buf: &mut [u8], val: u8) {
    buf[0] = val;
}

#[inline(always)]
pub fn encode_u16(buf: &mut [u8], val: u16) {
    buf[0] = (val >> 8) as u8;
    buf[1] = val as u8;
}

#[inline(always)]
pub fn encode_u32(buf: &mut [u8], val: u32) {
    buf[0] = (val >> 24) as u8;
    buf[1] = (val >> 16) as u8;
    buf[2] = (val >> 8) as u8;
    buf[3] = val as u8;
}

#[inline(always)]
pub fn decode_u8(buf: &[u8]) -> u8 {
    buf[0]
}

#[inline(always)]
pub fn decode_u16(buf: &[u8]) -> u16 {
    ((buf[0] as u16) << 8) +
    (buf[1] as u16)
}

#[inline(always)]
pub fn decode_u32(buf: &[u8]) -> u32 {
    ((buf[0] as u32) << 24) +
    ((buf[1] as u32) << 16) +
    ((buf[2] as u32) << 8) +
    (buf[3] as u32)
}


